<template>
  <div class="page-container">
    <!--面包屑-->
    <div class="breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item>会员中心</el-breadcrumb-item>
        <el-breadcrumb-item>会员管理</el-breadcrumb-item>
        <el-breadcrumb-item>会员列表</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <!--工具栏-->
    <div class="toolbar">
      <el-form :inline="true" :model="filters" :size="size">

        <el-row class="search-input">
          <el-row class="times mr30">
            <el-form-item label="标签名称：" prop="ruleNum" class="mb30 mr30" label-width="auto">
              <el-input
                v-model.trim="filters.labelName"
                @input="updateVal"
                placeholder="输入规则名称"
                class="w178"
              ></el-input>
            </el-form-item>

          </el-row>
        </el-row>
        <el-row class="search-button">
          <el-form-item>
            <kt-button icon="el-icon-search" :label="'搜索'" type="primary" @click="findPage(null)" />
          </el-form-item>

        </el-row>
      </el-form>
    </div>

    <!--表格内容栏-->
    <Jic-table
      :height="350"
      :tableList="pageResult"
      :tableHeaderList="filterColumns"
      @findPage="findPage"
      :showBatchDelete="false"
      :showEditOperation="false"
      :showCustomOperation="true"
      :totalSize="totalSize"
      @handlePageChange="handlePageChange"
      @handleSizeChange="handleSizeChange"
      :showSelection="true"
      :sortable="false"
      :showIndex="false"
      :operationWidth="300"
      ref="JicTable"
    ></Jic-table>

      <div slot="footer" class="dialog-footer">
        <el-button :size="size" @click="back" type="primary" plain>{{ $t("action.cancel") }}</el-button>
        <el-button :size="size" type="primary" @click.native="IntegralOnlineSure" class="btn">确定</el-button>
      </div>
  </div>
</template>

<script>
  import PopupTreeInput from "@/components/PopupTreeInput";
  import JicTable from  "@/components/jicComponentGallery/jicTable";
  import KtButton from "@/views/Core/KtButton";
  import TableColumnFilterDialog from "@/views/Core/TableColumnFilterDialog";
  export default {
    components: {
      PopupTreeInput,
      JicTable,
      KtButton,
      TableColumnFilterDialog
    },
    data() {
      return {
        HEIGHT: window.innerHeight,
        startTime:null,
        endTime:null,
        data:[],
        id:this.$route.query.id,
        businessId:"",
        deptMsg:localStorage.getItem('user'),//当前登录组织信息
        userId:localStorage.getItem("userId"),//当前登录用户id
        deptType:localStorage.getItem("deptType"),//当前登录用户所属组织类型
        pickerOptions: { disabledDate: this.disabledTime }, //当前时间之前禁用
        timeDialogShow: false, //设置上线时间弹窗
        deptMsg:localStorage.getItem('user'),//当前登录组织信息
        deptType:localStorage.getItem("deptType"),//当前登录用户所属组织类型
        imgUrl: "",
        totalSize: 0,
        size: "small",
        filters: {
          labelName:null
        },
        columns: [],
        filterColumns: [],
        pageRequest: { pageNum: 1, pageSize: 10 },
        pageResult: [],
        options: {},
        editLoading: false,
        dataFormRules: {
          labelName: [
            { required: true, message: "请输入标签名称", trigger: "blur" }
          ]

        },
      };
    },
    methods: {
      // 获取分页数据
      findPage: function(data) {
        let this_ = this;
        if (this_.filters == undefined || this_.filters == null) {
          this_.filters = {};
        }
        this_.filters.start = this.pageRequest.pageNum;
        this_.filters.limit = this.pageRequest.pageSize;
        this_.utils.request.findMemMemberCustomLabelPage(this_.filters, function(
          res
        ) {
          this_.pageResult = res.data.rows;
          this_.totalSize = Number(res.data.total);

        });
      },
      back(){
        this.$router.go(-1);//返回上一层
      },
      //左右分页点击
      handlePageChange(params) {
        if (params != null && params.number != null) {
          if (params.number != null) {
            this.pageRequest.pageNum = params.number;
          }

          this.findPage();
        }
      },
      // 换页刷新
      handleSizeChange: function(pageSize) {
        if (pageSize != null) {
          this.pageRequest.pageSize = pageSize.size;
          this.findPage();
        }
      },

      // 编辑
      submitForm: function() {
        let this_ = this;
        this.$refs.dataForm.validate(valid => {
          if (valid) {
            let params = Object.assign({}, this_.dataForm);
            this.utils.request.addMemMemberCustomLabel(params, function(res) {
              if (res.code == "0000") {
                this_.growthRuleShow = true;
              } else {
                this_.$message({
                  message: "" + res.msg,
                  type: "error"
                });
              }
              this_.findPage();
            });
          }
        });
      },
      // 处理表格列过滤显示
      displayFilterColumnsDialog: function() {
        this.$refs.tableColumnFilterDialog.setDialogVisible(true);
      },
      // 处理表格列过滤显示
      handleFilterColumns: function(data) {
        this.filterColumns = data.filterColumns;
        this.$refs.tableColumnFilterDialog.setDialogVisible(false);
      },
      // 处理表格列过滤显示
      initColumns: function() {
        this.columns = [
          { prop: "id", label: "ID", minWidth: 100 },
          { prop: "labelName", label: "标签名称", minWidth: 100 },
          { prop: "timesOfMarking", label: "标记次数", minWidth: 120 },
        ];
        var temp = [];
        $.each(this.columns, function(key, val) {
          temp.push(val);
        });
        this.filterColumns = temp;
      },
      resetForm(formName) {
        this.filters = {
          endTime: null,
          startTime: null,
          labelName:null
        };
        this.findPage();
      },
      //查询当前登录账号所属组织
      getDeptNameByDeptId() {
        let this_ = this;
        this_.utils.request.getDeptNameByDeptId({}, function(res) {
          this_.deptNames = res.data;
        });
      },
      //查询当前登录账号所属层级
      getDeptType() {
        let this_ = this;
        this.utils.request.getDeptType({}, function(res) {
          if (res.deptType == 0) {
            this_.operateDis = false;
            this_.whetherDelete = false;
          }
        });
      },
      //获取子平台列表
      queryDeptOption() {
        let query = {};
        let this_ = this;
        query.deptType = 1;
        this_.utils.request.queryDeptList(query, function(res) {
          if (res.code == "0000") {
            this_.deptOption = res.data;
          }
        });
      },
      //input框视图强制刷新
      updateVal() {
        this.$forceUpdate();
      },
      cancelDialog() {
        this.dialogVisible = false;
        this.findPage();
      },
      //上线按钮
      integralOnline(data) {
        let this_ = this;
        this_.timeDialogShow = true;
        this_.dataForm.id = data.row.id;
      },
      getCurrentTime() {
        let time = new Date();
        return time;
      },
      disabledTime(time) {
        return time.getTime() < Date.now() - 8.64e7;
      }
    },

    mounted() {
      this.initColumns();
      this.findPage();
      this.getDeptType();
      this.getDeptNameByDeptId();
      this.queryDeptOption();
    }
  };
</script>

<style lang='scss' scoped>
  .dialogInput {
    text-align: left;
    /deep/ .el-input {
      width: 400px;
    }
    /deep/ .el-input__inner {
      width: 400px !important;
    }
  }
  .dialogInput_short {
    text-align: left;
    /deep/ .el-input {
      width: 130px;
      margin-right: 10px;
    }
    /deep/ .el-input__inner {
      width: 130px !important;
    }
    /deep/ .el-form-item--small.el-form-item {
      margin-bottom: 0;
    }
  }
  .connection {
    display: inline-block;
    height: 32px;
    line-height: 32px;
  }
  .growRangeStart,
  .growRangeEnd {
    display: inline-block;
    width: 130px;
  }
  .positionDes {
    text-align: center;
    margin-top: 2%;
  }
  .ruleClass {
    font-size: 30px;
  }
  .btn {
  }
  .addDiyIntegraRulesBtn{
    position: relative;
    /deep/ .el-button{
      padding: 0 35px !important;
    }
    .addInfo{
      display:inline-block;
      width:20px;
      height: 20px ;
      color: #fff;
      background-color: orange;
      font-size: 12px;
      position: absolute;
      right: 10px;
      top: 50%;
      transform:translateY(-50%);
      border-radius: 20px;
      text-align: center;
      line-height: 20px;
      cursor: pointer;
      .hiddenImg{
        width: 400px;
        height: 400px;
        position: absolute;
        top: -305px;
        left: -380px;
        z-index: 999;
        border: 1px solid #000;
        display: none;
      }
    }
    &:hover .hiddenImg{
      display:block;
      transition: all 30s;
    }

  }
</style>
